##------------------------------------------------------------------------------
##
##	yasco-1.0 - Yet Another (Java)Script Obfuscator
##	Copyright (C) 2008-2011 Oliver Schieche <post@oliver-schieche.de>
##
##	Makes use of Yapp
##	Parse::Yapp - Copyright (c) 1998-2001, Francois Desarmenien, all right reserved.
##
##	$Id: Result.pm 8 2011-07-07 08:42:03Z goresplatter1844@gmail.com $
##------------------------------------------------------------------------------
package Yasco::Filter::Result;
#-------------------------------------------------------------------------------
use strict;
use warnings;
use vars qw/@ISA/;
use overload ('""' => 'stringify');

BEGIN {
	require Error;
	@ISA = qw/Error/;
	$Error::Debug = 1;
}
#-------------------------------------------------------------------------------
sub new
	{
	    my $self  = shift;
	    my $text  = shift;
	    my(@args) = ();

	    local $Error::Depth = $Error::Depth + 1;

	    @args = (-file => $1, -line => $2)
			if defined($text) && ($text =~ s/\s+at\s+(\S+)\s+line\s+(\d+)(?:,\s*<[^>]*>\s+line\s+\d+)?\.?\n?$//s);

	    $self->SUPER::new(-text => $text, @args);
	}

sub stringify
	{
	    my $self = shift;
		sprintf('%s at %s, line %d: %s\n%s', __PACKAGE__, $self->{'-file'}, $self->{'-line'}, $self->{'-text'}, $self->stacktrace);
	}
#-------------------------------------------------------------------------------
1